tmem: skip special case in alloc_heap_pages() if tmem holds no pages
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 23 Jun 2010 22:23:22 +0000 (23:23 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 23 Jun 2010 22:23:22 +0000 (23:23 +0100)
Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
xen/common/page_alloc.c
xen/common/tmem.c
xen/include/xen/tmem.h

index 6a1b6bde72cab9488606eb79467668d54ab800fa..10c6b2209303f6ad15614ef7c0c9e2df738f2892 100644 (file)
@@ -316,11 +316,14 @@ static struct page_info *alloc_heap_pages(
     spin_lock(&heap_lock);
 
     /*
-     * TMEM: When available memory is scarce, allow only mid-size allocations
-     * to avoid worst of fragmentation issues. Others try TMEM pools then fail.
+     * TMEM: When available memory is scarce due to tmem absorbing it, allow
+     * only mid-size allocations to avoid worst of fragmentation issues.
+     * Others try tmem pools then fail.  This is a workaround until all
+     * post-dom0-creation-multi-page allocations can be eliminated.
      */
     if ( opt_tmem && ((order == 0) || (order >= 9)) &&
-         (total_avail_pages <= midsize_alloc_zone_pages) )
+         (total_avail_pages <= midsize_alloc_zone_pages) &&
+         tmem_freeable_pages() )
         goto try_tmem;
 
     /*
index a3f236ae0bf50d3fe59f5727c695800a78c0c405..b917fae522fdf4a781b4ec894d682adccb7900f9 100644 (file)
@@ -2850,6 +2850,11 @@ EXPORT void *tmem_relinquish_pages(unsigned int order, unsigned int memflags)
     return pfp;
 }
 
+EXPORT unsigned long tmem_freeable_pages(void)
+{
+    return tmh_freeable_pages();
+}
+
 /* called at hypervisor startup */
 static int __init init_tmem(void)
 {
index 9140b08847fbd89d69036c822b2e20cb3451500a..cc191105059ec27092fa86fcb9292ccf1e58b4ff 100644 (file)
@@ -11,6 +11,7 @@
 
 extern void tmem_destroy(void *);
 extern void *tmem_relinquish_pages(unsigned int, unsigned int);
+extern unsigned long tmem_freeable_pages(void);
 extern int  opt_tmem;
 
 #endif /* __XEN_TMEM_H__ */